/**
 * @description 鼠标在指定的延迟后隐藏
 * @param {number} [delay=1500] 延迟时间(单位：毫秒)
 * @author yinxiaohai
 */
export function useHideCursor(delay: number = 1500) {
    var timer: NodeJS.Timeout | null = null;
    var hidding = false;
    return () => {
        window.addEventListener('mousemove', (event: MouseEvent) => {
            if (hidding) {
                hidding = false;
                return;
            }
            if (timer) {
                clearTimeout(timer!);
                timer = null;
            }
            document.body.style.cursor = 'unset'
            timer = setTimeout(() => {
                hidding = true;
                document.body.style.cursor = 'none'
            }, delay)
        })
    }
}

